{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import jieba, re"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "def filter_zsz(str):\n",
    "    return len(str)!=0 and re.search(r'^([\\ \\|\\[\\]\\_\\-\\`\\?\\!\\>\\<\\{\\},\\.\\;\\:\\\"\\'\\`\\↩¶【】\\d，：。；…《》－～·、？！“”（）〖〗〔〕\\+]+|[a-zA-Z]{1,2}|back|and|yes|no|true|false|or|the|this|that|those|there|is|here|good|bad|ok|fine|fail|have|start|stop|pause|restart|和|的|都|在|上|下|该)$',str)==None\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Building prefix dict from the default dictionary ...\n",
      "Loading model from cache C:\\Users\\zszen\\AppData\\Local\\Temp\\jieba.cache\n",
      "Loading model cost 0.860 seconds.\n",
      "Prefix dict has been built successfully.\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tokens ['访问', '左侧', 'blog', '点点', '点滴', '选择', '每天', '滴滴', '标题', '点点滴滴', '记录', '标题栏', '跳转', 'zszen', '细节', 'tec', '上册']\n"
     ]
    }
   ],
   "source": [
    "title = \"Zszen's Tec Blog ¶ 点点滴滴记录每天细节 访问左侧和上册标题栏选择跳转 ¶\"\n",
    "tokens = jieba.lcut_for_search(title.replace('\\n', ''), True)\n",
    "tokens = [x.lower() for x in tokens]\n",
    "tokens = filter(filter_zsz, tokens)\n",
    "tokens = list(set(tokens))\n",
    "print(\"tokens\", tokens)"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "7c20c3a3c6d975aebf3af203ee807c6eaf2448e28fccb64b1b06ce3985531924"
  },
  "kernelspec": {
   "display_name": "Python 3.9.7 ('base')",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
